<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.7
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############

class IUsers_User extends JFX_User{

    public $params;
    public $username;
    public $userid;
    public $floodCheck = array();
    public $country = 'NZ';
    

    public function __construct(){
        $this->params = array(
            'user_id' => 0,
            'id' => 0,
            'username' => 'Guest'
        );
        if(!isset($_SESSION['IUsers_User'])) $_SESSION['IUsers_User'] = $this->params;
    }

    public static function startSession(){
        $USER = new IUsers_User;
        $USER->params = $_SESSION['IUsers_User'];
        $USER->userid = $USER->params['id'];
        $USER->username = $USER->params['username'];
        return $USER;
    }

    public function login($uData){
        $this->params = array_merge($_SESSION['IUsers_User'], $uData);
        $_SESSION['IUsers_User'] = $this->params;
        $this->userid = $uData['id'];
        $this->username = $uData['username'];
    }

    public function isLoggedIn(){
        if((int) $this->userid === 0) return false;
        else return true;
    }

}